package Demo_01;

public class Thread_03 {
    static boolean isQuit = false;
    public static void main(String[] args) {
        Thread th = new Thread(() -> {

            while(!isQuit) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        System.out.println("休眠被终止 ...");
                        break;
                    }
                    System.out.println("我在执行...");
            }
        });
        th.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("快终止线程！！");
        isQuit = true;
    }
}
